//	uView 将它所有的工具类，全都放在了 uni.$u 这个对象上
const http = uni.$u.http

const getClassify = () => http.get('https://eggblog.bluej.cn/api/classify/get', {
	params: {
		projectId: 168
	}
})

const getBlogByClassify = (id) => http.get('https://eggblog.bluej.cn/api/blog/searchByClassifyId', {
	params: {
		id,
		projectId: 168
	}
})

const getBlogByKeywords = (keyword) => http.get('https://eggblog.bluej.cn/api/blog/searchByInput', {
	params: {
		keyword,
		projectId: 168
	}
})

const createBlog = (data, token) => http.post('https://eggblog.bluej.cn/api/blog/create', data, {
	header: {
		"x-token": token
	}
})

const registerUser = (data) => http.post('https://eggblog.bluej.cn/api/user/register', data, )

const getMyBlog = (token) => http.get('https://eggblog.bluej.cn/api/blog/getMyBlog', {
	header: {
		"x-token": token
	},
	params: {
		projectId: 168,
		limit: 10,
		offset: 0
	}
})

// 通过博客id 找博客 
const getBlogById = (id) => http.get('https://eggblog.bluej.cn/api/blog/search', {
	params: {
		id,
		projectId: 168
	}
})

// 点赞博客
// const likeBlog = (token,id) => http.post('http://eggblog.bluej.cn/api/blog/likeBlog', {
// 	header: {
// 		"x-token": token
// 	},
// 	params: {
// 		id,
// 		projectId: 168
// 	}
// })

//	用户模块
const login = (data) => http.post('https://eggblog.bluej.cn/api/user/login', data)

//	文件模块
const upload = (data, token) => http.upload('https://eggblog.bluej.cn/api/imgUpload', {
	header: {
		"x-token": token
	},
	formData: {
		file: data
	}
})

export {
	getClassify,
	getBlogByClassify,
	getBlogByKeywords,
	createBlog,
	login,
	upload,
	registerUser,
	getMyBlog,
	getBlogById
}
